using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using WozLib.UI.Ink.SketchObjects;

namespace WozLib.UI.Ink.SketchProperties
{
  public class StringSketchProperty : SketchProperty
  {

    [XmlAttribute("Data")]
    public string Data
    {
      get
      {
        return _Data;
      }
      set
      {
        _Data = value;

        FirePropertyChanged("Data");
        NotifyPropertyChanged();
      }

    } private string _Data;

    public StringSketchProperty(string data, WozPropertyType wozPropertyType)
      : base(wozPropertyType)
    {
      Data = data;
    }

    public StringSketchProperty()
    {
    }

    public override object Clone()
    {
      return new StringSketchProperty(Data.Clone() as string, this.WozPropertyType);
    }

    /// <summary>
    /// Returns true if .equals on the string Data is true
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public override bool Equals(object obj)
    {
      if (obj is StringSketchProperty && (obj as StringSketchProperty).Data == Data)
      {
        return true;
      }
      else
      {
        return false;
      }
    }

    public override CascadingProperty CreateCascadingProperty(List<ISketchObject> iWozObjects)
    {
      if (this.WozPropertyType == WozPropertyType.Font)
      {
        return new FontCascadingProperty(iWozObjects, this);
      }
      else
      {
        return new StringCascadingProperty(iWozObjects, this);
      }
    }
  }
}
